#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>

#define SERVER_IPV6   "::1"

#define SERVER_PORT 8080

#define BUFF_SIZE 	1024

int main()
{
	char buf[BUFF_SIZE] = "abc\n";
	
	struct sockaddr_in6 sockaddr_svr = {0};
	
	int sock_cln = 0;
	
	/* create a socket */
	sock_cln = socket( AF_INET6, SOCK_DGRAM, IPPROTO_UDP );
	if( -1 == sock_cln )
	{
		printf( "create sock error\n" );
		return -1;
	}
	
	/* sockaddr info the server */
	sockaddr_svr.sin6_family = PF_INET6;
	sockaddr_svr.sin6_port = htons( SERVER_PORT );
	inet_pton( AF_INET6, SERVER_IPV6, &sockaddr_svr.sin6_addr );
	
	/* send data here */
	int size_sockaddr = sizeof(sockaddr_svr);
	int sent = sendto( sock_cln, buf, strlen(buf), 0, (struct sockaddr *)&sockaddr_svr, size_sockaddr );
	printf( "sent: %d\n", sent );
	
	/* clean up */
	close( sock_cln );
	
	sleep( 5 );
	return 0;
}